package zsh.service.impl;

import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import zsh.aop.Log;
import zsh.aop.LogType;
import zsh.mapper.AccountMapper;
import zsh.service.IAccountService;

import java.math.BigDecimal;

@Service
@AllArgsConstructor
public class AccountService implements IAccountService {

    private AccountMapper accountMapper;
    @Override
    @Transactional(rollbackFor = Exception.class)
    @Log(logType = LogType.ADD,method = "转账",desc = "转了钱一个增一个减")
    public void transfer(String from, String to, BigDecimal money) {
        accountMapper.outAccount(from,money);
//        int a = 1/0;
        accountMapper.insertAccount(to,money);
    }
}
